package com.szrt.day20170504.ch05;

public class TicketThread implements Runnable {
	
	/**
	 * 一共有一百张票
	 * 
	 * 100 99 98 ...1 
	 */
	private  int  ticket =100;

	@Override
	public void run() {
		/**
		 * 可能1个窗口卖100张票  其他的窗口一张票都没卖  
		 */
		for(int index =1; index<=100;index++){
			
			if(ticket>=1){
				
				try {
					
					//?
					System.out.println(Thread.currentThread().getName()+ "开始买票：");
					Thread.currentThread().sleep(100);
					System.out.println(Thread.currentThread().getName()+"票号="  + ticket--);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
			
		}
		
	}

}
